<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <!--<div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :span="6">
            <a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-select style="width: 100%" v-model="queryParam.isTimeLimit" @change="handleChange" :allowClear="true" placeholder="请选择">
                <a-select-option :value="true">
                  已超期
                </a-select-option>
                <a-select-option :value="false">
                  未超期
                </a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="相关人" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-select
                show-search
                :allowClear="true"
                placeholder="请选择"
                option-filter-prop="children"
                v-model="queryParam.createBy"
                style="width: 100%"
                :filter-option="filterOptionCreateBy"
                @change="changeCreateBy">
                <a-select-option :value="item.realname" v-for="(item,index) in createByData" :key="index">
                  {{item.realname}}
                </a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form>
    </div>-->

    <!-- table区域-begin -->
    <div>
      <div class="list">
        <van-list
          v-model="loading"
          :finished="finished"
          offset="100"
          finished-text="没有更多了"
          @load="onLoadList"
          :immediate-check="false"
        >
          <div
            class="customer-list"
            v-for="(item,i) in dataSource"
            :key="i"
          >
            <div>
              <div class="name">客户姓名：{{ item.customerInfo.name || '无' }}</div>
              <div class="contact">
                <span>项目地址：{{ item.customerInfo.address || '无' }}</span>
              </div>
              <div class="contact">
                <span>房屋户型：{{ getDictValue('customer_info_house_type',item.customerInfo.houseType) }}</span>
              </div>
              <div class="contact">
                <span>房屋面积：{{ item.customerInfo.houseArea || '无' }}</span>
              </div>
              <div class="contact">
                <span>联系方式：{{item.customerInfo.phone || '无'}}</span>
                <span style="margin-left: 20px">相关人：{{ item.createBy || "无" }}</span>
              </div>
              <div class="contact">
                <span>项目状态：{{ getDictValue('project_manage_project_status',item.projectStatus) }}</span>
              </div>
              <div class="contact">
                <span>开工日期：{{item.startWorkDate || '无'}}</span>
                <span style="margin-left: 20px">竣工日期：{{item.CompletionDate || '无'}}</span>
              </div>
              <div class="contact">
                <span>总工期：{{item.totalTimeLimit || '无'}}</span>
                <span style="margin-left: 20px;margin-right: 20px">剩余工期：{{item.surplusTimeLimit || '无'}}</span>
                <span>超期天数：{{item.exceedTimeLimitNum || '无'}}</span>
              </div>
            </div>
          </div>
        </van-list>
      </div>

      <!--<a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="progressSlot" slot-scope="text, record">
          <a-progress :percent="record.projectProgress" style="padding-right: 10px"/>
        </span>
      </a-table>-->
    </div>

    <!--<gh-project-manage-modal ref="modalForm" @ok="modalFormOk"></gh-project-manage-modal>-->
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import {mixinDevice} from '@/utils/mixin'
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import {filterDictTextByCache} from '@comp/dict/JDictSelectUtil'
  import {getAction} from "../../../../../api/manage";
  import {filterObj} from '@/utils/util';

  export default {
    name: 'buildingProject',
    mixins: [JeecgListMixin, mixinDevice],
    components: {},
    data() {
      return {
        projectStatusList: [],
        createByData:[],
        description: '在建工程表页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: "center",
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '姓名',
            align: "center",
            width: 120,
            dataIndex: 'customerInfo.name'
          },
          {
            title: '项目地址',
            align: "center",
            dataIndex: 'customerInfo.address'
          },
          {
            title: '房屋户型',
            align: "center",
            dataIndex: 'customerInfo.houseType',
            customRender: (text) => {
              //字典值翻译通用方法
              return filterDictTextByCache('customer_info_house_type', text);
            }
          },
          {
            title: '房屋面积',
            align: "center",
            dataIndex: 'customerInfo.houseArea'
          },
          {
            title: '联系方式',
            align: "center",
            dataIndex: 'customerInfo.phone'
          },
          {
            title: '项目状态',
            align: "center",
            dataIndex: 'projectStatus',
            customRender: (text) => {
              //字典值翻译通用方法
              return filterDictTextByCache('project_manage_project_status', text);
            }
          },
          {
            title: '相关人',
            align: "center",
            dataIndex: 'createBy'
          },
          {
            title: '创建日期',
            align: "center",
            width: 200,
            dataIndex: 'createTime'
          },
          {
            title: '开工日期',
            align: "center",
            width: 200,
            dataIndex: 'startWorkDate'
          },
          {
            title: '竣工日期',
            align: "center",
            width: 200,
            dataIndex: 'completionDate'
          },

          {
            title: '总工期',
            align: "center",
            dataIndex: 'totalTimeLimit'
          },
          {
            title: '剩余工期',
            align: "center",
            dataIndex: 'surplusTimeLimit',
            customRender:function (text) {
              if (text == null){
                return "--";
              }else {
                return text;
              }
            }
          },
          {
            title: '超期天数',
            align: "center",
            dataIndex: 'exceedTimeLimitNum',
            customRender:function (text) {
              if (text == null){
                return "--";
              }else {
                return text;
              }
            }
          },
        ],
        /* 查询条件-请不要在queryParam中声明非字符串值的属性 */
        queryParam: {},
        /* 数据源 */
        dataSource: [],
        labelCol: {
          xs: {span: 24},
          sm: {span: 5},
        },
        wrapperCol: {
          xs: {span: 24},
          sm: {span: 16},
        },
        url: {
          list: "/ghProjectManage/queryBuildingProject",
          delete: "/ghProjectManage/delete",
          deleteBatch: "/ghProjectManage/deleteBatch",
          exportXlsUrl: "/ghProjectManage/exportXls",
          importExcelUrl: "/ghProjectManage/importExcel",
          queryUserList: "/sys/user/allList",
        },
        dictOptions: {},
        finished: false,
      }
    },
    created() {
      this.loadData();
      this.loadUserListData();
    },
    computed: {
      importExcelUrl: function () {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      //加载用户列表
      loadUserListData() {
        getAction(this.url.queryUserList).then((res) => {
          if (res.success) {
            this.createByData = res.result.records||res.result;
          }
        })
      },
      filterOptionCreateBy(input, option) {
        return (
          option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        );
      },
      changeCreateBy(value){
        this.loadData(1);
      },
      onLoadList(e){
        this.ipagination.current++
        this.loadData(this.ipagination.current)
      },
      loadData(arg) {
        if (!this.url.list) {
          this.$message.error("请设置url.list属性!")
          return
        }
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
          this.dataSource = []
          this.finished = false;
        }
        var params = this.getQueryParams();//查询条件
        this.loading = true;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
            this.dataSource = [...this.dataSource, ...res.result.records]
            if (res.result.total) {
              this.ipagination.total = res.result.total;
            } else {
              this.ipagination.total = 0;
            }
            //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          } else {
            this.$message.warning(res.message)
          }
          if(res.result.records.length<10){
            this.finished = true;
          }
        }).finally(() => {
          this.loading = false
        })
      },
      handleChange(value){
        this.loadData(1);
      },
      getDictValue(code,value){
        if (value != null){
          return filterDictTextByCache(code,value)
        }else {
          return "无"
        }
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';

  /deep/ .van-dropdown-menu__bar{
    height: 30px;
    box-shadow: none;
    border: 1px solid lightgrey;
    border-radius: 5px;
  }

  .list{
    overflow-y: scroll;
    height:100vh;
  }
  ::-webkit-scrollbar {
    display: none;
  }
  .customer-list {
    align-items: center;
    border-top: 1px solid #d9d9d9;
    /*height: 120px;*/
  }
  .name{
    margin-top: 10px;
    margin-bottom: 5px;
    font-size: 13px;
    color: #161616;
    line-height: normal;
  }
  .contact{
    font-size: 12px;
    color: #a39f9f;
    margin-bottom: 5px;
  }
</style>